import React from 'react';
import ReactDOM from 'react-dom'

const modalRoot = document.getElementById("extend")
class Modal extends React.Component {
    constructor(props) {
      super(props);
      this.el = document.createElement('div');
    }
  
    componentDidMount() {
      modalRoot.appendChild(this.el);
    }
    // componentDidUpdate(){
    //   if(document.body.style.overflow==='')
    //     document.body.style.overflow = 'hidden'
    //   else
    //     document.body.style.overflow = ''
    // }
    componentWillUnmount() {
      modalRoot.removeChild(this.el);

    }
    
    render() {
      return ReactDOM.createPortal(
        this.props.children,
        this.el,
      );
    }
}

export default Modal